package 算法.力扣;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: 谢君臣
 * @create: 2020-12-12 19:29
 * @founction: XXXX
 */
public class Lc1553_1 {
    public static void main(String[] args) {
        Map<Integer, Integer> map = new HashMap<>();
        int n = 10;
        map.put(1, 1);
        map.put(2, 2);
        map.put(3, 2);
        System.out.println(minDays(n, map));
//        return map.get(n);
    }

    public static int minDays(int n, Map<Integer, Integer> map) {
        if (n < 3) {
            return n;
        }
        if (map.containsKey(n)) {
            return map.get(n);
        }
        int ans = 1 + Math.min(minDays(n / 2, map) + n % 2, minDays(n / 3, map) + n % 3);
        map.put(n, ans);
        return ans;
    }
}
